package com.siecomzg.bean;

public class APDU_RESP
{
  public short LenOut;
  public byte[] DataOut = new byte[2048];
  public byte SWA;
  public byte SWB;

  public APDU_RESP()
  {

  }

  public APDU_RESP(short LenOut, byte[] DataOut, byte SWA, byte SWB)
  {
    this.LenOut = LenOut;
    this.DataOut = DataOut;
    this.SWA = SWA;
    this.SWB = SWB;
  }

  public static APDU_RESP parseFromByteArray(byte[] apduResp){
    int LenOut = (apduResp[1] & 0xff) | ((apduResp[0] << 8) & 0xff00);
    byte[] DataOut = new byte[LenOut];
    System.arraycopy(apduResp,2,DataOut,0,DataOut.length);
    byte SWA =apduResp[LenOut+2];
    byte SWB =apduResp[LenOut+3];
    return  new APDU_RESP((short) LenOut,DataOut,SWA,SWB);
  }
  public static void parseFromByteArray(byte[] apduResp,APDU_RESP ApduResp){
    ApduResp.LenOut = (short) ((apduResp[1] & 0xff) | ((apduResp[0] << 8) & 0xff00));
    ApduResp.DataOut = new byte[ApduResp.LenOut];
    System.arraycopy(apduResp,2,ApduResp.DataOut,0,ApduResp.DataOut.length);
    ApduResp.SWA =apduResp[ApduResp.LenOut+2];
    ApduResp.SWB =apduResp[ApduResp.LenOut+3];
  }

}